int recursive_matrix_chain(int *p,int i,int j,int m[N+1][N+1],int s[N+1][N+1])
{
    if(i==j)
       m[i][j] = 0;
    else
    {
        int k;
        m[i][j] = MAXVALUE;
        for(k=i;k<j;k++)
        {
            int temp = recursive_matrix_chain(p,i,k,m,s) +recursive_matrix_chain(p,k+1,j,m,s) + p[i-1]*p[k]*p[j];
            if(temp < m[i][j])
            {
                m[i][j] = temp;
                s[i][j] = k;
            }
        }
    }
    return m[i][j];
}